package com.zik.vod.controller;


import com.atguigu.ggkt.model.vod.Subject;
import com.zik.swagger.result.Result;
import com.zik.vod.service.SubjectService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author zik
 * @since 2023-05-01
 */
@RestController
@RequestMapping("/admin/vod/subject")
public class SubjectController {

    @Autowired
    private SubjectService subjectService;

    /**
     * 懒加载课程列表
     * @param id 课程id
     * @return list<Subject> 课程列表
     */
    @ApiOperation("课程分类查询")
    @GetMapping("/getChildSubject/{id}")
    public Result getChildSubject(@PathVariable Long id){
       List<Subject> list =  subjectService.selectSubjectList(id);
       return Result.ok(list);
    }

    /**
     * 课程分类导出
     */
    @ApiOperation("课程分类导出")
    @GetMapping("exportData")
    public void exportData(HttpServletResponse response) {
        subjectService.exportData(response);
    }
    /**
     * 课程分类导入功能
     */
    @ApiOperation("课程分类导入")
    @PostMapping("importData")
    public Result insertData(MultipartFile file) {
        subjectService.importData(file);
        return Result.ok();
    }
}

